<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base data-ice="baseUrl" href="../../">
  <title data-ice="title">src/wpPublicPath.js | live2d-widget.js</title>
  <link type="text/css" rel="stylesheet" href="css/style.css">
  <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
  <script src="script/prettify/prettify.js"></script>
  <script src="script/manual.js"></script>
<meta name="description" content="Add the Sseexxyyy live2d to webpages."><meta property="twitter:card" content="summary"><meta property="twitter:title" content="live2d-widget.js"><meta property="twitter:description" content="Add the Sseexxyyy live2d to webpages."></head>
<body class="layout-container" data-ice="rootContainer">

<header>
  <a href="./">Home</a>
  
  <a href="identifiers.html">Reference</a>
  <a href="source.html">Source</a>
  
  <div class="search-box">
  <span>
    <img src="./image/search.png">
    <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
  </span>
    <ul class="search-result"></ul>
  </div>
<a style="position:relative; top:3px;" href="https://github.com/xiazeyu/live2d-widget.js"><img width="20px" src="./image/github.png"></a></header>

<nav class="navigation" data-ice="nav"><div>
  <ul>
    
  <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/index.js~L2Dwidget.html">L2Dwidget</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-PlatformManager">PlatformManager</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-captureFrame">captureFrame</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-theRealInit">theRealInit</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-cManager">cManager</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-cModel">cModel</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createElement">createElement</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCurrentPath">getCurrentPath</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-cDefine">cDefine</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-currWebGL">currWebGL</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#config">config</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-configApplyer">configApplyer</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#lib">lib</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-EYE_STATE">EYE_STATE</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DBaseModel">L2DBaseModel</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DExpressionMotion">L2DExpressionMotion</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DExpressionParam">L2DExpressionParam</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DEyeBlink">L2DEyeBlink</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DMatrix44">L2DMatrix44</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DModelMatrix">L2DModelMatrix</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DMotionManager">L2DMotionManager</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DPartsParam">L2DPartsParam</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DPhysics">L2DPhysics</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DPose">L2DPose</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DTargetPoint">L2DTargetPoint</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-L2DViewMatrix">L2DViewMatrix</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-Live2DFramework">Live2DFramework</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-MatrixStack">MatrixStack</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ModelSettingJson">ModelSettingJson</a></span></span></li>
</ul>
</div>
</nav>

<div class="content" data-ice="content"><h1 data-ice="title">src/wpPublicPath.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">/**
 * @description Automatic locate the publicPath and set it up for webpack.
 */


&apos;use strict&apos;;

/**
 * Get current script path
 * @return {String} The path of current script
 * @example
 * get &apos;file:///C:/git/live2d-widget/dev/bundle.js&apos; or &apos;https://www.host.com/test/js/bundle.js&apos;
 */

function getCurrentPath(){

  try{

    // FF, Chrome, Modern browsers
    // use their API to get the path of current script

    // a.b();
    // console.log(&apos;wpStage1&apos;);

    return document.currentScript.src;

    if(DOC.currentScript){ // FF 4+
      return DOC.currentScript.src;
    }

  }catch(e){

    // document.currentScript doesn&apos;t supports

    // console.log(&apos;wpStage2&apos;);

    // Method 1
    // https://github.com/mozilla/pdf.js/blob/e081a708c36cb2aacff7889048863723fcf23671/src/shared/compatibility.js#L97
    // IE, Chrome &lt; 29

    let scripts = document.getElementsByTagName(&apos;script&apos;);
    return scripts[scripts.length - 1].src;

/*
    // Method 2
    // parse the error stack trace maually
    // https://github.com/workhorsy/uncompress.js/blob/master/js/uncompress.js#L25

    let stack = e.stack;
    let line = null;

    // Chrome and IE
    if (stack.indexOf(&apos;@&apos;) !== -1) {
      line = stack.split(&apos;@&apos;)[1].split(&apos;\n&apos;)[0];
    // Firefox
    } else {
      line = stack.split(&apos;(&apos;)[1].split(&apos;)&apos;)[0];
    }
    line = line.substring(0, line.lastIndexOf(&apos;/&apos;)) + &apos;/&apos;;
    return line;
*/
/*
    // Method 3
    // https://www.cnblogs.com/rubylouvre/archive/2013/01/23/2872618.html

    let stack = e.stack;
    if(!stack &amp;&amp; window.opera){
      // Opera 9&#x6CA1;&#x6709;e.stack,&#x4F46;&#x6709;e.Backtrace,&#x4F46;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x53D6;&#x5F97;,&#x9700;&#x8981;&#x5BF9;e&#x5BF9;&#x8C61;&#x8F6C;&#x5B57;&#x7B26;&#x4E32;&#x8FDB;&#x884C;&#x62BD;&#x53D6;
      stack = (String(e).match(/of linked script \S+/g) || []).join(&apos; &apos;);
    }
    if(stack){
      // e.stack&#x6700;&#x540E;&#x4E00;&#x884C;&#x5728;&#x6240;&#x6709;&#x652F;&#x6301;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x5927;&#x81F4;&#x5982;&#x4E0B;:
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;// chrome23:
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;// @ http://113.93.50.63/data.js:4:1
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;//&#xA0;firefox17:
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;//&#xA0;@http://113.93.50.63/query.js:4
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;//&#xA0;opera12:
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;//&#xA0;@http://113.93.50.63/data.js:4
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;//&#xA0;IE10:
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;//&#xA0;@ Global code (http://113.93.50.63/data.js:4:1)
&#xA0;&#xA0;&#xA0;&#xA0;  stack = stack.split(/[@ ]/g).pop(); // &#x53D6;&#x5F97;&#x6700;&#x540E;&#x4E00;&#x884C;,&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x7A7A;&#x683C;&#x6216;@&#x4E4B;&#x540E;&#x7684;&#x90E8;&#x5206;
      stack = stack[0] == &apos;(&apos; ? stack.slice(1,-1) : stack;
      return stack.replace(/(:\d+)?:\d+$/i, &apos;&apos;); // &#x53BB;&#x6389;&#x884C;&#x53F7;&#x4E0E;&#x6216;&#x8BB8;&#x5B58;&#x5728;&#x7684;&#x51FA;&#x9519;&#x5B57;&#x7B26;&#x8D77;&#x59CB;&#x4F4D;&#x7F6E;
    }
    let nodes = head.getElementsByTagName(&apos;script&apos;); // &#x53EA;&#x5728;head&#x6807;&#x7B7E;&#x4E2D;&#x5BFB;&#x627E;
    for(var i = 0, node; node = nodes[i++];){
      if(node.readyState === &apos;interactive&apos;){
        return node.className = node.src;
      }
    }
*/
  }

}

// expose the path to the global,
// and wp will finish the following work
__webpack_public_path__ = getCurrentPath().replace(/[^/\\\\]+$/, &apos;&apos;);
if (process.env.NODE_ENV === &apos;development&apos;){
  console.log(`Live2Dwidget: publicPath: ${__webpack_public_path__}`);
}

export {
  getCurrentPath,
}
</code></pre>

</div>

<footer class="footer">
  Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>

<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>
